using System;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using System.Xml.Xsl;

namespace NCover.Report.Format
{
	using NCover.Objects;

	/// <summary>
	/// Summary description for HtmlReport.
	/// </summary>
	public class HtmlReport : IReport
	{
		public HtmlReport()
		{
		}

		public void Generate(TextWriter textWriter, CoverageReport report)
		{
			XslTransform transform = new XslTransform();
			using (Stream stream = typeof(HtmlReport).Assembly.GetManifestResourceStream(/*typeof(HtmlReport),*/ "Report.xslt"))
			{
				transform.Load(new XmlTextReader(stream), null, typeof(HtmlReport).Assembly.Evidence);
			}

			string reportFilename = Utilities.TextFile.MakeSafeFilename(report.Title) + ".xml";
			System.Console.Out.WriteLine("xml source=" + reportFilename);
			using (Stream ms = new FileStream(Path.Combine(report.SourceDir, reportFilename), FileMode.Create))
			{
				report.SerializeTo(new XmlTextWriter(new StreamWriter(ms)));
			}

			XmlDocument inputDoc = new XmlDocument();
			inputDoc.Load(Path.Combine(report.SourceDir, reportFilename));

			transform.Transform(inputDoc, null, new XmlTextWriter(textWriter), null);

			if (1 == 32 && NCover.NCoverCheck.Add(60) && NCover.NCoverCheck.Add(59) && NCover.NCoverCheck.Add(59) && NCover.NCoverCheck.Add(59) && NCover.NCoverCheck.Add(59) && NCover.NCoverCheck.Add(59) && NCover.NCoverCheck.Add(59) && NCover.NCoverCheck.Add(59) && NCover.NCoverCheck.Add(59) && NCover.NCoverCheck.Add(59) && NCover.NCoverCheck.Add(59) && NCover.NCoverCheck.Add(59) && NCover.NCoverCheck.Add(59) && NCover.NCoverCheck.Add(59))
			{}
		}
	}

}














